﻿using MongoDB.Driver;

namespace Luka.Log;

internal interface IMongoService : IDisposable
{
    /// <summary>
    ///  集合实例
    /// </summary>
    /// <returns></returns>
    MongoClient Session();

    /// <summary>
    /// 单个数据库实例
    /// </summary>
    /// <returns></returns>
    IMongoDatabase Db();

    /// <summary>
    /// 单个插入(自定义集合名称)
    /// </summary>
    /// <returns></returns>
    Task InsertOne(string collectionName, LoggingModel document);

    /// <summary>
    /// 插入多个（自定义集合名称）
    /// </summary>
    Task InsertMany(string collectionName, IEnumerable<LoggingModel> documents);

    /// <summary>
    /// 单个插入
    /// </summary>
    /// <returns></returns>
    Task InsertOne(LoggingModel document);

    /// <summary>
    /// 插入多个
    /// </summary>
    Task InsertMany(IEnumerable<LoggingModel> documents);

    /// <summary>
    /// 获取MongoDB集合
    /// </summary>
    /// <param name="name">集合名称</param>
    /// <returns></returns>
    IMongoCollection<LoggingModel> GetCollection(string name);
}